package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 陈秋雨
 * @version 1.0
 * @description:
 * @date 2024/02/24 上午 3:55
 */
@Mapper
public interface SetmealDishMapper {

    /**
     * 根据套餐id查询菜品集合
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getDishBySetmealId(Long setmealId);

    /**
     * 根据菜品id查询套餐id集合
     * @param dishIds
     * @return
     */
    @Select("select setmeal_id from setmeal_dish where dish_id in (#{dishIds})")
    List<Long> getSetmealIdsByDishId(@RequestParam List<Long> dishIds);

    /**
     * 批量插入套餐和菜品的关联关系
     * @param setmealDishes
     */
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     *删除套餐菜品关系表中的数据
     * @param ids
     */
    void deleteBySetmealId(List<Long> setmealIds);

    /**
     * 根据套餐id删除套餐和菜品的关联关系
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealIdOne(Long setmealId);
}
